package com.offcn.controller;

import com.offcn.entity.Product;
import com.offcn.service.CardService;
import com.offcn.service.OrderService;
import com.offcn.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ProductController {
     @Resource
    private ProductService productService;
     @Resource
     private CardService cardService;
     @RequestMapping(value = "/thirdProduct")
     public  String thirdProduct(@RequestParam(value = "thirdId",required = false)int thirdId, Model model, HttpSession session){
         session.removeAttribute("firstId");
         session.removeAttribute("secondId");
         session.setAttribute("thirdId", thirdId);
       List<Product> productList=   productService.findThirdProduct(thirdId);
       if(productList !=null && productList.size()>0){
           session.setAttribute("product",productList.get(0));
       }
      // session.setAttribute("productList",productList);
        return "productDeal";
     }








}
